home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include "define.h"
-
- /* ドライブステータス情報の読み取り */
- /*
- * decice_no: device number (Towns CD-ROM -> 0)
- * return: 0 -> 正常終了, 0以外 -> エラー
- * sector_size <- 2048 , 2336 or 2340 (sector size)
- * sector_max <- 最大論理セクタ数
- */
- int cdr_status(int device_no, int *sector_size, long int *sector_max)
- {
- union REGS reg;
-
- reg.h.ah = 0x02;
- reg.h.al = (0xC0 | (u_char) device_no);
- reg.h.ch = 0x00;
-
- int86(0x93, ®, ®);
-
- if (sector_max) {
- *sector_max = (u_long) reg.h.bl << 16;
- *sector_max += reg.x.dx;
- }
-
- if (sector_size) {
- if (reg.h.al == 0x04) {
- *sector_size = 2048;
- } else if (reg.h.al == 0x08) {
- *sector_size = 2336;
- } else {
- *sector_size = 2340; /* (reg.h.al == 0x09) のはず */
- }
- }
-
- if (reg.h.ah == 0) {
- return 0;
- } else if (reg.h.ah == 0x02) { /* device number error */
- return DEVERR;
- } else { /* (reg.h.ah == 0x80) hard ware error */
- return reg.x.cx;
- }
- }
-
-